package day07;

import java.util.Random;
import java.util.Scanner;

/*
猜数字小游戏
训练目标:while(ture)自造死循环 + break
 */
public class Guessing {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Random rand = new Random()  ;
        int arr = rand.nextInt(99999)+1;
        int i = 0;
        while (true){
            System.out.println(arr);
            int num = rand.nextInt(99999+1);
            if (num != arr){
                if (num >arr ){
                    System.out.println("猜大了");
                }else {
                    System.out.println("猜小了");
                }
                i++;
                if (i >=500 ){
//                    System.out.println(i);
                    System.out.println("超出限制");
                    break;
                }
            }else {
                System.out.println("猜对了");
                System.out.println("一共猜了" +i);
                break;
            }

        }



    }
}
